import { requestClient } from '#/api/request';

export namespace ToolTypeApi {
  export type Params = object;
  export interface GetToolTypeReq {
    pageNum: number;
    pageSize: number;
  }
  export interface Row {
    attr1?: null | string;
    attr2?: null;
    attr3?: number;
    attr4?: number;
    codeFlag?: string;
    createBy?: string;
    createTime?: Date;
    maintenPeriod?: null | number;
    maintenType?: null | string;
    params?: Params;
    remark?: string;
    searchValue?: null;
    toolTypeCode?: string;
    toolTypeId?: null | number;
    toolTypeName?: string;
    updateBy?: string;
    updateTime?: Date | null;
  }
  export interface GetToolTypeResp {
    total: number;
    rows: Row[];
    code: number;
    msg: string;
  }

  export interface Datum {
    searchValue: null;
    createBy: string;
    createTime: Date;
    updateBy: string;
    updateTime: Date | null;
    remark: string;
    params: Params;
    toolTypeId: number;
    toolTypeCode: string;
    toolTypeName: string;
    codeFlag: string;
    maintenType: string;
    maintenPeriod: number;
    attr1: null;
    attr2: null;
    attr3: number;
    attr4: number;
  }

  export interface GetToolTypeAllResp {
    msg: string;
    code: number;
    data: Datum[];
  }
}

// 获取类型列表
export const tmToolTypeList = (params: ToolTypeApi.GetToolTypeReq) =>
  requestClient.get<ToolTypeApi.GetToolTypeResp>('/mes/tm/tooltype/list', {
    params,
  });

export const tmToolTypeAll = () =>
  requestClient.get<ToolTypeApi.GetToolTypeAllResp>('/mes/tm/tooltype/listAll');

// 修改
export const updateToolType = (data: ToolTypeApi.Row) =>
  requestClient.put<ToolTypeApi.GetToolTypeResp>('/mes/tm/tooltype', data);

// 增加
export const addToolType = (data: ToolTypeApi.Row) =>
  requestClient.post<ToolTypeApi.GetToolTypeResp>('/mes/tm/tooltype', data);

// 删除
export const deleteToolType = (id: string) =>
  requestClient.delete<ToolTypeApi.GetToolTypeResp>(`/mes/tm/tooltype/${id}`);
